package com.mh.alltest.test2;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MqttMyClient {

    MqttClient mqttClient;


    @Autowired
    public void initMqttClient(){
        log.info("初始化.......");
        MqttClient client = null;
        try {
            client = new MqttClient();
            client.setName("client1");
        }catch (Exception e){
            e.printStackTrace();
        }
        this.mqttClient = client;
    }

//    public void setMqttClient(){
//        this.mqttClient = getMqttClient();
//    }

    /**
     * 订阅
     */
    public void sub(){
        mqttClient.sub();
        log.info(mqttClient.getName());
    }



}
